package com.boss.hr.controller;

import com.boss.hr.entity.UserEntity;
import com.boss.hr.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/user")
/***
 * @Author lys(cherish)
 * @Description 用户控制层
 * @Date  2019/3/2
 **/
public class UserController {

    //  引入用户服务上
    @Autowired
    private IUserService userService;

    /***
     * @Author lys(cherish)
     * @Description 用户列表查询
     * @Date  2019/3/2
     * @Param []
     * @return org.springframework.web.servlet.ModelAndView
     **/
    @RequestMapping("/list")
    public ModelAndView getAllUser(){
        ModelAndView mv = new ModelAndView("user");
        List<UserEntity> users = userService.getAll();
        Map<String, Object> model = mv.getModel();
        model.put("allUser",users);
        return mv;
    }
    /***
     * @Author lys(cherish)
     * @Description 系统欢迎页
     * @Date  2019/3/2
     * @Param []
     * @return java.lang.String
     **/
    @RequestMapping("/index")
    @ResponseBody
    public String getIndex(){
        return "welcome";
    }

}
